package com.lanhe;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;
import org.springframework.scheduling.annotation.EnableScheduling;

import java.net.InetAddress;

/**
 * 启动程序
 *
 * @author lanhe
 */
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
@Slf4j
@RefreshScope
@EnableScheduling
public class LanHeApplication
{
    public static void main(String[] args)
    {
	    ConfigurableApplicationContext application = SpringApplication.run(LanHeApplication.class, args);
        try {
            Environment env = application.getEnvironment();
            String ip = InetAddress.getLocalHost().getHostAddress();
            String port = env.getProperty("server.port");
            log.info("\n----------------------------------------------------------\n\t" +
                    "\n\t(♥◠‿◠)ﾉﾞ  兰禾教育   ლ(´ڡ`ლ)ﾞ  \n\t" +
                    "Local: \t\thttp://localhost:" + port + "/\n\t" +
                    "External: \thttp://" + ip + ":" + port + "/\n\t" +
                    "\n----------------------------------------------------------");
        } catch (Exception e){
            e.printStackTrace();
            log.error("报错原因=========>",e);
        }
    }
}
